package com.lgmshare.k3.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

/**
 * @author: LGM
 * @description: TODO
 * @email: lgmshare@gmail.com
 * @QQ:994976626
 * @datetime: 2017/6/11
 */
public class DialogUtils {

    public static Dialog createProgressDialog(Context context, String message) {
        LoadingDialog dialog = new LoadingDialog(context);
        dialog.setMessage(message);
        dialog.show();
        return dialog;
    }

    public static Dialog createProgressDialog(Context context, String message, boolean cancelable) {
        LoadingDialog dialog = new LoadingDialog(context);
        dialog.setMessage(message);
        dialog.setCancelable(cancelable);
        dialog.setCanceledOnTouchOutside(cancelable);
        dialog.show();
        return dialog;
    }

    public static Dialog createSimpleOkDialog(Context context, String right, final View.OnClickListener listener, String title, String content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnPositiveClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (listener != null) {
                    listener.onClick(v);
                }
            }
        });
        return dialog;
    }

    public static Dialog createSimpleOkDialog(Context context, int right, final View.OnClickListener listener, int title, int content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnNegativeClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (listener != null) {
                    listener.onClick(v);
                }
            }
        });
        return dialog;
    }

    public static Dialog createSimpleOkCancelDialog(Context context, int right, final View.OnClickListener rightListener, int left, final View.OnClickListener leftListener, String title, String content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnPositiveClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (rightListener != null) {
                    rightListener.onClick(v);
                }
            }
        });
        dialog.setOnNegativeClick(left, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (leftListener != null) {
                    leftListener.onClick(v);
                }
            }
        });
        return dialog;
    }

    public static Dialog createSimpleOkCancelDialog(Context context, String right, final View.OnClickListener rightListener, String left, final View.OnClickListener leftListener, int title, int content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnPositiveClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (rightListener != null) {
                    rightListener.onClick(v);
                }
            }
        });
        dialog.setOnNegativeClick(left, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (leftListener != null) {
                    leftListener.onClick(v);
                }
            }
        });
        return dialog;
    }

    public static Dialog createSimpleOkCancelDialog(Context context, String right, final View.OnClickListener rightListener, String left, final View.OnClickListener leftListener, String title, String content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnPositiveClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (rightListener != null) {
                    rightListener.onClick(v);
                }
            }
        });
        dialog.setOnNegativeClick(left, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (leftListener != null) {
                    leftListener.onClick(v);
                }
            }
        });
        return dialog;
    }

    public static Dialog createSimpleOkCancelDialog(Context context, int right, final View.OnClickListener rightListener, int left, final View.OnClickListener leftListener, int title, int content) {
        final CommonDialog dialog = new CommonDialog(context);
        dialog.setTitle(title);
        dialog.setContent(content);
        dialog.setOnPositiveClick(right, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (rightListener != null) {
                    rightListener.onClick(v);
                }
            }
        });
        dialog.setOnNegativeClick(left, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (leftListener != null) {
                    leftListener.onClick(v);
                }
            }
        });
        return dialog;
    }
}
